﻿using Abp.Domain.Entities.Auditing;
using Basefr.Core.Auth.Entities;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Basefr.Core.Entities
{
    /// <summary>
    /// 自动记录修改和删除信息的Entity基类
    /// </summary>
    public abstract class AuditedEntityBase<TPrimary, TUser> : EntityBase<TPrimary>, IFullAudited<TUser>
        where TPrimary : struct
        where TUser : UserBase<TUser>
    {
        /// <summary>
        /// 创建人
        /// </summary>
        //[ForeignKey(nameof(CreatorUserId))]
        [NotMapped]
        public virtual TUser CreatorUser { get; set; }


        /// <summary>
        /// 删除人ID
        /// </summary>
        public long? DeleterUserId { get; set; }

        /// <summary>
        /// 删除人
        /// </summary>
        //[ForeignKey(nameof(DeleterUserId))]
        [NotMapped]
        public virtual TUser DeleterUser { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletionTime { get; set; }


        ///// <summary>
        ///// 最后修改人ID
        ///// </summary>
        //public long? LastModifierUserId { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        //[ForeignKey(nameof(LastModifierUserId))]
        [NotMapped]
        public virtual TUser LastModifierUser { get; set; }

        ///// <summary>
        ///// 最后修改时间
        ///// </summary>
        //public DateTime? LastModificationTime { get; set; }
    }

    /// <summary>
    /// 自动记录修改和删除信息的Entity基类
    /// </summary>
    public abstract class AuditedEntityBase<TUser> : AuditedEntityBase<int, TUser>
        where TUser : UserBase<TUser>
    {

    }
}
